1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.universAAL.samples.sensor.simulator;
21
22 import java.awt.EventQueue;
23
24 import org.osgi.framework.BundleActivator;
25 import org.osgi.framework.BundleContext;
26 import org.universAAL.middleware.container.ModuleContext;
27 import org.universAAL.middleware.container.osgi.uAALBundleContainer;
28 import org.universAAL.middleware.container.utils.LogUtils;
29
30
31
32
33
34 public class Activator implements BundleActivator {
35
36
37
38 private static ModuleContext mcontext;
39 LocationContextPublisher lp = null;
40 SensorSimulatorGUI frame = null;
41
42
43
44
45
46
47
48
49 public void start(BundleContext bcontext) throws Exception {
50
51 Activator.mcontext = uAALBundleContainer.THE_CONTAINER
52 .registerModule(new Object[] { bcontext });
53
54 EventQueue.invokeLater(new Runnable() {
55 public void run() {
56 try {
57 LocationContextPublisher lp = new LocationContextPublisher(
58 mcontext);
59
60 LampStatePublisher lampStatePublisher = new LampStatePublisher(
61 mcontext);
62 RoomTemperaturePublisher roomTemperaturePublisher = new RoomTemperaturePublisher(
63 mcontext);
64
65 RoomHumidityPublisher roomHumidityPublisher = new RoomHumidityPublisher(
66 mcontext);
67
68 SensorSimulatorGUI frame = new SensorSimulatorGUI(lp,
69 lampStatePublisher, roomTemperaturePublisher,
70 roomHumidityPublisher);
71 frame.setVisible(true);
72 } catch (Exception e) {
73 e.printStackTrace();
74 }
75 }
76 });
77
78 LogUtils
79 .logInfo(
80 mcontext,
81 this.getClass(),
82 "start",
83 new Object[] { "smp.sensor.simulator.gui bundle has started." },
84 null);
85 }
86
87
88
89
90
91
92
93 public void stop(BundleContext context) throws Exception {
94 LogUtils
95 .logInfo(
96 mcontext,
97 this.getClass(),
98 "stop",
99 new Object[] { "smp.sensor.simulator.gui bundle has stopped." },
100 null);
101 mcontext = null;
102 lp = null;
103 frame = null;
104
105 }
106
107 }